package com.cf.base.comm.tools;

import android.content.Context;
import android.graphics.drawable.Drawable;

import androidx.annotation.ColorRes;
import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import androidx.core.content.ContextCompat;

public class ResourcesUtils {
    public static BaseSingleton<ResourcesUtils> singleton = new BaseSingleton<ResourcesUtils>() {
        @Override
        protected ResourcesUtils create() {
            return new ResourcesUtils();
        }
    };

    /**
     * ApplicationContext
     */
    private Context context;

    private ResourcesUtils() {
    }

    void init(Context context) {
        this.context = context.getApplicationContext();
    }


    public String getString(@StringRes int res) {
        return context.getResources().getString(res);
    }

    public String getString(@StringRes int res, Object... o) {
        return context.getResources().getString(res, o);
    }

    public float getDimension(@DimenRes int dimen) {
        return context.getResources().getDimension(dimen);
    }

    public Drawable getDrawable(@DrawableRes int id) {
        return ContextCompat.getDrawable(context, id);
    }

    public int getColor(@ColorRes int id) {
        return ContextCompat.getColor(context, id);
    }


}
